package com.ruoyi.web.controller.wxqy;

import com.ruoyi.common.annotation.ControllerAuthority;
import com.ruoyi.common.constant.ErrorConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.NumberUtils;
import com.ruoyi.qywx.model.query.GroupChatQuery;
import com.ruoyi.qywx.model.vo.GroupChatManagerVo;
import com.ruoyi.qywx.service.inters.ExtGroupChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author : hcl
 * @Date : 2023/9/7 15:06
 */
@RestController
@ControllerAuthority
@RequestMapping("/wxqy/group-chat")
public class GroupChatController extends BaseController {
    @Autowired
    private ExtGroupChatService chatService;

    @GetMapping("/manager/list")
    public AjaxResult groupChatManagerList(GroupChatQuery query) {
        startPage();
        return AjaxResult.success(getDataTable(chatService.groupChatList(getTeamId(), query)));
    }

    @GetMapping("/detail")
    public AjaxResult groupChatDetail(Long chatId) {
        if (NumberUtils.isFalse(chatId)) {
            return error(ErrorConstants.PARAMS_ERR);
        }
        return chatService.groupChatDetail(getTeamId(), chatId);
    }

    @GetMapping("/chat-members")
    public AjaxResult groupChatMembers(Long chatId,
                                       @RequestParam(required = false) String nickName,
                                       @RequestParam(required = false) Boolean isDelete) {
        if (NumberUtils.isFalse(chatId)) {
            return error(ErrorConstants.PARAMS_ERR);
        }
        startPage();
        return AjaxResult.success(getDataTable(chatService.groupChatMembers(getTeamId(), chatId,nickName, isDelete)));
    }
}
